﻿<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>用户管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 用户管理 <span class="c-gray en">&gt;</span> 用户列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form id="putTime" name="time">
		<div class="text-c"> 日期范围：
			<input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" id="datemin" name="datemin" class="input-text Wdate" style="width:120px;">
			-
			<input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" id="datemax" name="datemax" class="input-text Wdate" style="width:120px;">
			<button type="submit" class="btn btn-success radius" id="search" name=""><i class="Hui-iconfont">&#xe665;</i> 搜用户</button>
		</div>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> </span> <span class="r">共有数据：<span th:id="strong" th:text="${num}"></span> 条</span> </div>
	<div class="mt-20">
	<table class="table table-border table-bordered table-hover table-bg table-sort">
		<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="all" value=""></th>
				<th width="50">排序</th>
				<th width="100">昵称</th>
				<th width="90">手机</th>
				<th width="130">注册时间</th>
				<th width="70">身份</th>
				<!--<th width="100">操作</th>-->
			</tr>
		</thead>
		<tbody>
			<tr class="text-c" th:each="s,u:${user}">
				<td><input type="checkbox" th:value="${s.userId}" name="tal"></td>
				<td th:text="${u.index+1}"></td>
				<td><u style="cursor:pointer" class="text-primary" onclick="member_show(this,'member-show.html','','360','470')" th:text="${s.nickname}"></u></td>
				<td th:text="${s.phone}"></td>
				<td th:text="${s.createtime}"></td>
				<td class="td-status" th:text="${s.NAME}"></td>
				<!--<td class="td-manage"><a style="text-decoration:none" onClick="member_frozen(this,'10001')" href="javascript:;" title="冻结"><i class="Hui-iconfont">&#xe631;</i></a></td>-->
			</tr>
		</tbody>
	</table>
	</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
$(function(){
	$('.table-sort').dataTable({
		"aaSorting": [
		    [ 1, "asc" ]
		],//默认第几个排序
		"bStateSave": false,//状态保存
		"aoColumnDefs": [
//		  {"bVisible": false, "aTargets": [ 3 ]}, //控制列的隐藏显示
		  {"orderable":false,"aTargets":[0,2,4]}// 制定列不参与排序
		]
	});

    $("#putTime").validate({
        rules: {
            datemin:{
                dateISO:true
			},
            datemax:{
                dateISO:true
			},
        },
        onkeyup:false,
        focusCleanup:false,
        success:"valid",
        submitHandler:function(form){
            $.fn.dataTable.ext.search.push(
                function( settings, data, dataIndex ) {
                    var min = new Date($("#datemin").val());
                    var max = new Date($("#datemax").val());
                    var time = new Date(data[4]);

                    if (min<=time && time<= max ) {
                        return true;
                    }
                    return false;
                }
            );
            if(form.childNodes.item(1).childNodes.item(1).value != null && form.childNodes.item(1).childNodes.item(4).value){
                $('.table-sort').DataTable().draw();
			}else {
                location.replace(location.href)
			}
        }
    })
});
/*作品详情*/
function works_show(title,url,id){
    var index = layer.open({
        type: 2,
        title: title,
        content: url
    });
    layer.full(index);
}
/*用户-查看*/
function member_show(obj,url,id,w,h){
    var title =$(obj).html();
    id=$(obj).parents("tr").find("td").eq(0).children().val();
    url=id
	layer_show(title,url,w,h)
}

/*用户-冻结*/
function member_frozen(obj,id){
	layer.confirm('确认要冻结吗？',function(index){
        id=$(obj).parents("tr").find("td").eq(0).children().val();
		$.ajax({
			type: 'POST',
			url: '/frozenUser/'+id,
			dataType: 'json',
			success: function(data){
			    if(data ==1){
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe6e1;</i></a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已停用</span>');
                    $(obj).remove();
                    layer.msg('冻结成功!',{icon:1,time:1000});
				}else {
                    layer.msg('冻结失败!',{icon:2,time:1000});
				}
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}

/*批量删除*/
function datadel() {
    var check_value = [];
    $('input[name="tal"]:checked').each(function () {
        check_value.push($(this).val());
    });
    layer.confirm('确认要删除吗？',function(index){
        $.ajax({
            url: '/batch/delete/user',
            type: 'POST',
            dataType: 'json',
            data: {
                'ids': check_value
            },
            success:function (result) {
                if(result==true){
                    $('input[name="tal"]:checked').each(function () {
                        check_value.push($(this).parent().parent().remove());
                    });
                    layer.msg('已删除!',{icon:1,time:1000});
				}else if(result==false){
                    layer.msg('删除失败!',{icon:1,time:1000});
				}else {
                    layer.msg('系统出错!',{icon:1,time:1000});
				}
            }
        });
    });
}

/*单个选项全选中是，全选选项选中；反之全选选项取消*/
$().ready(function () {
    $('input[name="tal"]').click(function(){
        var number = 0;
        var count = 0;
        $('input[name="tal"]').each(function(){
            number++;
            if($(this).prop("checked")==true){
                count++;
            }
            if(count==number){
                $('input[name="all"]').prop("checked", true);
            }else{
                $('input[name="all"]').prop("checked", false);
            }
        })
    });
})

</script> 
</body>
</html>